package Operation;

import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-13
 * Time: 12:29
 */
public class DeleteOperation implements IOperation{


    @Override
    public void work(BookList book) {
        System.out.println("删除图书");
        System.out.println("请输入你要删除的书籍");
        Scanner scan =new Scanner(System.in);
        String name = scan.nextLine();
        int i =0;
        int currSize = book.getUsedSize();
        for(i =0;i< book.getUsedSize();++i) {
            if(book.getPos(i).bookName.equals(name)) {
                 book.setUsedSize(currSize-1);
                System.out.println("书籍删除成功");
                return;
            }
        }
        if(i==book.getUsedSize()) {
            System.out.println("没有找到你要查找的这本书~~~~~无法删除");
        }
    }
}
